<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Enter student grades</title>
</head>
<body>
<%
    String url = "jdbc:mysql://localhost:3306/studentdb?serverTimezone=UTC";
    String db_name = "root";
    String db_pass = "123456";
    String sql = "select * from score";
%>
<form  method="post" action="ScoreAddServlet">
<div>
    学生编号:&nbsp;<input name="txtPname1" id="txtPname1" type="text"  style="width:127px;"/>&nbsp;
    课程编号:&nbsp;<input name="txtPname2" id="txtPname2" type="text"  style="width:127px;"/>&nbsp;
    平时成绩:&nbsp;<input name="txtPname3" id="txtPname3" type="text" style="width:127px;"/>&nbsp;
    考试成绩:&nbsp;<input name="txtPname4" id="txtPname4" type="text"  style="width:127px;"/>&nbsp;
    <input type="submit" name="Button1" value="提交" id="Button1"/><br/>

</div>
</form>
<p></p>

<div>
    <div>
        <table width="100%" cellspacing="" cellpadding="15" border="" style="color:#333333;border-collapse:collapse;">
            <tr style="color:White;background-color:#027DB4;font-weight:bold;">
                <th>全选</th>
                <th>学生编号</th>
                <th>课程编号</th>
                <th>平时成绩</th>
                <th>考试成绩</th>
                <th>操作</th>
            </tr>

            <tr style="color:#333333;background-color:#FFFBD6;">
                <td><input type="checkbox"/></td>
                <td>1</td>
                <td>1</td>
                <td>89</td>
                <td style="width:200px;">98</td>
                <td><a href="">【提交】</a></td>
            </tr>
            <%
                try {
                    Class.forName("com.mysql.cj.jdbc.Driver");
                    Connection conn = DriverManager.getConnection(url, db_name, db_pass);
                    Statement stmt = conn.createStatement();
                    ResultSet rs = stmt.executeQuery(sql);
                    while (rs.next()) {
            %>
            <tr style="color:#333333;background-color:#FFFBD6;">
                <td><input type="checkbox"/></td>
                <td><%= rs.getString(1) %></td>
                <td><%= rs.getString(2) %></td>
                <td><%= rs.getString(3) %></td>
                <td style="width:200px;"><%= rs.getString(4) %></td>
                <td><a href="">【提交】</a></td>
            </tr>
            <%
                    }
                    stmt.close();
                    conn.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            %>
        </table>
    </div>


</div>


</body>
</html>